﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
    <link href="../CSS/style1.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/style4.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.showModalDialog.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.pager.js" type="text/javascript"></script>
    <script type="text/javascript">
        function date2str(date) {
            //null判断
            if (date == null) return "";
            //去掉左右的斜杠
            date = date.replace(/\//g, "");
            //将其转为一个日期对象
            eval("var d = new " + date + ";");
            //返回最终结果
            return d.getFullYear() + "年" + (d.getMonth() + 1) + "月" + d.getDate() + "日";
        }
        function Load() {
            $(".dataTable tr:gt(0)").live("click", function () {
                $(".dataTable tr:gt(0)").css("background-color", "white");
                $(this).css("background-color", "red");
                $(".dataDiv div:first").css("background-image", "url(../images/bg.gif)");
                $(".dataDiv div:last").css("background-image", "url()");
            });
        }
        //显示服务类型
        function ServiceType() {
            $.ajax({
                url: "ServiceCreate.asmx/SelectServiceType",
                type: "post",
                data: JSON.stringify({}),
                dataType: "json",
                contentType: "application/json",
                success: function (obj) {
                    var sel1 = $("#select1");
                    for (var i = 0; i < obj.d.length; i++) {
                        sel1.append('<option value="' + obj.d[i].STName + '">' + obj.d[i].STName + '</option>');
                    }
                }, error: function (xmlhttp) {
                    alert("错误：" + xmlhttp.responseText);
                }
            });

        };
        //进行分页
        $(function () {
            ServiceType(); //显示服务类型
            reloadList();
            Load();
        });
        //刷新
        function reloadList() {
            //注册分页器控件
            $("#pageDiv").empty().pager("ServiceAllot.ashx", { action: "paging" }, function (data) {
                //展示查询的结果
                $("#tb1 tr:gt(0)").remove();
                var tb1 = $("#tb1").get(0);
                for (var i = 0; i < data.length; i++) {
                    var tr = tb1.insertRow(-1);
                    tr.insertCell(-1).innerHTML = data[i].CSName || "";
                    tr.insertCell(-1).innerHTML = data[i].CSTitle || "";
                    tr.insertCell(-1).innerHTML = data[i].STName || "";
                    tr.insertCell(-1).innerHTML = data[i].CSCreateName || "";
                    tr.insertCell(-1).innerHTML = date2str(data[i].CSCreateDate) || "";
                    if (data[i].CSDueName==null) {
                        tr.insertCell(-1).innerHTML = '<input type="text" value="双击选择" readonly="readonly" ondblclick="showEmp(' + data[i].CSID + ')" style="text-align:center;width:87px" />';
                    }else{
                        tr.insertCell(-1).innerHTML = '<input type="text" value="' + data[i].CSDueName + '" readonly="readonly" ondblclick="showEmp(' + data[i].CSID + ')" style="text-align:center;width:87px" />';
                    }
                    
                }
            });

        };
        function showEmp(CSID) {
            
            $.showModalDialog("../publicPage/SelectEmp.htm?data=" + Math.random(), null, 200, 220, function (CSDueID) {
                if (CSDueID) {
                    var ch = {
                        action: "updateCSID",
                        CSID: parseInt(CSID),
                        CSDueID: parseInt(CSDueID)
                    };
                    $.post("ServiceAllot.ashx", ch, function (r) {
                        if (r == "1") {
                            reloadList();
                        } else {
                            alert("服务分配人修改失败");
                        }
                    });
                }
            });
        };
        function cha() {
            var ser = {
                action: "select",
                CSName: $("#txtCSname").val(),
                STName: $("#select1").val()
            };
            $("#pageDiv").empty().pager("CustomServicesWeb.ashx", ser, function (data) {
                //展示查询的结果
                $("#tb1 tr:gt(0)").remove();
                var tb1 = $("#tb1").get(0);
                for (var i = 0; i < data.length; i++) {
                    var tr = tb1.insertRow(-1);
                    tr.insertCell(-1).innerHTML = data[i].CSName || "";
                    tr.insertCell(-1).innerHTML = data[i].CSTitle || "";
                    tr.insertCell(-1).innerHTML = data[i].STName || "";
                    tr.insertCell(-1).innerHTML = data[i].CSCreateName || "";
                    tr.insertCell(-1).innerHTML = date2str(data[i].CSCreateDate) || "";
                    tr.insertCell(-1).innerHTML = '<input type="text" style="text-align:center;width:87px" value="' + data[i].CSDueName + '" readonly="readonly" ondblclick="showEmp(' + data[i].CSID + ')" />' || "";
                }
            });

        };

    </script>
</head>
<body>
<div id="desDiv">
    <span>服务分配</span><br />
    对于客户提出的咨询、建议、投诉等服务分配专人进行处理
</div>
<table class="tableEdit" style="width:600px">
        <tr>
            <th>
                客户名称：
            </th>
            <td>
                <input type="text" id="txtCSname" style="color:blue;" />
            </td>
            <th>
                服务类型：
            </th>
            <td>
                <select id="select1" style="color:blue;width:80px">
                    <option value="">全部</option>
                </select>
            </td>
        </tr>
        <tfoot>
            <tr>
                <td colspan="8">
                    <input type="button" value="查询" onclick="cha();" />
                </td>
            </tr>
        </tfoot>
</table>
<br />
<div id="dataDiv">
    <div id="headDiv">
    </div>
    <table class="dataTable" id="tb1">
        <tr>
            <th align="center">客户名称</th>
            <th align="center">概要</th>
            <th align="center">服务类型</th>
            <th align="center">创建人</th>
            <th align="center">创建时间</th>
            <th align="center">服务分配人</th>
        </tr>
    </table>
    <div id="pageDiv">
    
    </div>
</div>
</body>
</html>
